home *** CD-ROM | disk | FTP | other *** search
Wrap
GW-BASIC | 1983-08-18 | 3.8 KB | 74 lines
1 REM DIRECT AND INDIRECT RATE ADJUSTMENT 2 REM Written by Tracy L. Gustafson, M.D. 3 REM Round Rock, Texas. Version 2.0, 1983 5 DEF SEG=&H40 6 A=PEEK(&H17): IF NOT(A AND &H20) THEN POKE &H17,(A AND (NOT &H20)) OR &H20 7 DEF SEG: KEY OFF: SCREEN 0,0: WIDTH 80: COLOR 7,0,1 10 CLEAR: OPTION BASE 1: DEFINT A-C,N,T,Z: DEFSTR D 20 CLS: PRINT TAB(20);"KEY";STRING$(28,205);"CLOSE" 25 PRINT TAB(20);"OPEN CALCULATING ADJUSTED RATES OPEN" 30 PRINT TAB(20);"SCREEN";STRING$(28,205);"LOAD" 40 PRINT: PRINT TAB(6);: INPUT "What is the name of the DATAFILE you wish to analyze? ",FILE$ 45 ON ERROR GOTO 500 50 OPEN FILE$ FOR INPUT AS #1: INPUT #1, A,C 70 DIM D(A,C),CS(A,C),N$(A),X(A),X2(A),SD(A),MD(A),T(A) 80 FOR T=1 TO A: INPUT #1, T(T): NEXT 90 FOR T=1 TO A: FOR Z=1 TO C: INPUT #1, D(T,Z): NEXT: NEXT 100 FOR T=1 TO A: FOR Z=1 TO T(T): INPUT #1, CS(T,Z): NEXT: NEXT 110 FOR T=1 TO A: INPUT #1, N$(T),X(T),X2(T),MD(T),SD(T): NEXT: CLOSE #1:PRINT 115 PRINT TAB(5);: INPUT "Do you want the DIRECT or INDIRECT adjustment method? (D or I) ",A$ 120 PRINT: IF A$="D" OR A$="d" THEN 130 ELSE IF A$="i" OR A$="I" THEN 200 ELSE BEEP: GOTO 115 130 INPUT;"Enter the SAMPLE NUMBER of the study rates to be adjusted: ",NS1 135 IF NS1<=A THEN PRINT " `";N$(NS1);"'" ELSE GOSUB 490: GOTO 130 140 INPUT;"Enter the SAMPLE NUMBER of the standard population figures: ",NS2 145 IF NS2<=A THEN PRINT " `";N$(NS2);"'": PRINT ELSE GOSUB 490: GOTO 140 150 IF T(NS1)<>T(NS2) THEN GOSUB 495: GOTO 130 155 INPUT "Rates in the study group are given per what number? ",RD 160 SR=0: N=T(NS1) 170 FOR Z=1 TO N: SR=SR+VAL(D(NS1,Z))*VAL(D(NS2,Z)): NEXT 180 SAR=SR/X(NS2): PRINT :PRINT 185 PLAY "MB T160 L32 N8 N12 N15 N20 N24 N27 N32 N36 N39 N44... N27 L5 N8" 190 COLOR 0,7: PRINT TAB(15);"Direct-adjusted rate = ";SAR;"per";RD;TAB(75): COLOR 7,0: PRINT 195 PRINT: PRINT "Remember, if the number of cases in any cell is < 5, then"; 196 PRINT TAB(30);"indirect rate adjustment may be more appropriate.": GOTO 470 200 INPUT;"Enter the SAMPLE NUMBER of the study population figures: ",NS1 205 IF NS1<=A THEN PRINT " `";N$(NS1);"'" ELSE GOSUB 490: GOTO 200 210 INPUT;"Enter the SAMPLE NUMBER of the standard population rates: ",NS2 215 IF NS2<=A THEN PRINT " `";N$(NS2);"'": PRINT ELSE GOSUB 490: GOTO 210 220 IF T(NS1)<>T(NS2) THEN GOSUB 495: GOTO 200 230 INPUT "Rates in the standard population are given per what number? ",RD 240 E=0: N=T(NS1) 250 FOR Z=1 TO N: E=E+VAL(D(NS1,Z))*VAL(D(NS2,Z)): NEXT 260 E=E/RD: PRINT :PRINT: PRINT TAB(5); 270 PRINT "How many cases were observed in the study group `";N$(NS1);: INPUT "' ? ",NO 280 PRINT: PRINT TAB(8);"Expected number of cases in the study group =";E 290 PRINT: COLOR 0,7: PRINT TAB(15);"Observed to expected ratio = ";NO/E;TAB(75);: COLOR 7,0 292 COLOR 23: PRINT: PRINT: AP=CSRLIN:PRINT TAB(25);"CALCULATING PROBABILITY"; 295 AF=0: CO=NO: CE=0: IF E<CO THEN CO=CO-1: AF=1 300 IF NO>1000 THEN 360 310 IF CO=0 THEN SF=1 ELSE SF=E+1 320 F=E: FOR Z=2 TO CO: F=F*E/Z: IF F>1E+22 THEN F=F*0: SF=SF* 0: CE=CE+1 325 IF F<0 THEN 330 ELSE SF=SF+F: NEXT Z 330 SL=LOG(SF)-E+CE*50: IF SL>80 THEN P=0 ELSE P=EXP(SL)*2 340 IF AF=1 THEN P=2-P 350 GOTO 410 360 X=(NO-E)*(NO-E)/E: IF X>31 THEN P=0: GOTO 410 370 R=1.77245: S=1: I=1: K=((X/2)^(0.5)*2)/(EXP(X/2)*R): B=3 380 I=I*X/B: S=S+I: B=B+2: IF I>0 THEN 380 400 P=1-K*S 410 PLAY "MB T160 L32 N8 N12 N15 N20 N24 N27 N32 N36 N39 N44... N27 L5 N8" 430 COLOR 0,7: LOCATE AP,1: PRINT TAB(6);"The probability of observing ";NO;" or "; 440 IF AF=1 THEN PRINT "more cases ="; ELSE PRINT "fewer cases ="; 450 IF P<=9E-09 THEN PRINT " < 10 (-8)"; ELSE IF P>=0.95 THEN PRINT " > .95"; ELSE PRINT P; 455 PRINT TAB(75): COLOR 7,0: PRINT 460 IF NO>100 THEN PRINT:PRINT TAB(5);"Remember, the Poisson calculation of probability":PRINT TAB(20);"may not be applicable when the observed rate is > 5% ." 470 PRINT:PRINT:INPUT " Do you want to perform another rate adjustment using this DATAFILE? ",A$ 480 IF A$="y" OR A$="Y" THEN CLS: GOTO 115 485 END 490 BEEP: PRINT TAB(15);"This datafile has only";A;"samples.": RETURN 495 IF T(NS1)<>T(NS2) THEN PRINT:PRINT "These 2 samples do not have the same number of elements----":PRINT TAB(37);"direct rate adjustment cannot be performed.":RETURN 500 BEEP: PRINT: IF ERL=50 AND ERR=53 THEN PRINT: PRINT TAB(13); "I cannot find a file by that name on drive "; ELSE 530 510 IF MID$(FILE$,2,1)=":" THEN DR$=LEFT$(FILE$,2) ELSE DR$="A:" 520 PRINT DR$: PRINT "Your files are:": FILES DR$+"*.*": RESUME 40 530 ON ERROR GOTO 0